package Object.useObject;

/**
 * Enjoy programming!!!
 * Time: 2021/11/5 -  15:16
 */
public class User {
    private int id;
    public String name;
    public char gender;
    public String password;

    public void show() {
        System.out.println("用户信息如下：");
        System.out.println("用户编号：" + this.id);
        System.out.println("用户姓名：" + this.name);
        System.out.println("用户性别：" + this.gender);
        System.out.println("用户密码：" + this.password);
    }
    public void setId(int id){
        if (id < 0){
            this.id = 1;
        }
        else{
            this.id = id;
        }
    }
    public int getId(){
        return id;
    }
}

class Test {
    public static void main(String[] args) {
        User user = new User();
        user.setId(-1) ;
        user.name = "张三";
        user.gender = '男';
        user.password = "root";
        user.show();
    }

}
